<template>
  <view class="order-info" :style="'height:' + height + 'rpx'">
    <view class="info-top">
      <view class="top-left">
        <image
          :src="itemInfo.personPhoto == '' ? imageUrl : itemInfo.personPhoto"
        />
        <view class="user-name">{{ itemInfo.personName }}</view>
      </view>
      <view class="top-right">
        <view class="new-order" v-if="itemInfo.noticeStatus == '2'">{{
          isFinishEstimate ? "新评价" : "新订单"
        }}</view>
        <img :src="arrowRight" class="arrow-right" />
      </view>
    </view>
    <view class="info-bottom" v-if="isFinishEstimate == false">
      <view
        class="bottom-item"
        v-for="(item, index) in bottomInfoList"
        :key="index"
      >
        {{ item.title }} {{ item.value || "" }}
      </view>
    </view>
    <view class="info-bottom-finish-estimate" v-else>
      <view class="estimate">
        {{ itemInfo.rateDetailList[4].rateContent || "暂无评价" }}
      </view>
      <view class="date">
        {{ itemInfo.completeRateTime || "" }}
      </view>
    </view>
  </view>
</template>

<script>
import { updateConsultantNoticeStatus } from "@/api/modules/orderManage.js";
import { orderDetail } from "@/api/modules/career.js";

export default {
  props: {
    itemInfo: {
      type: Object,
      default: {},
    },
    isFinishEstimate: {
      type: Boolean,
      default: false,
    },
    consultantRateTime: {
      type: String,
      default: "0",
    },
  },
  data() {
    return {
      arrowRight: this.$imgBaseSelf + "common/arrow-right0712.png",
      imageUrl:
        "https://img200.yl1001.com/resume-profile/2024/04/27/d96e220b-f25c-4e7c-89b4-777cec5eefc0.jpg",
      height: 508,
      bottomInfoList: [
        {
          title: "手机号：",
          value: "0",
        },
        {
          title: "所属项目：",
          value: "0",
        },
      ],
    };
  },
  methods: {
    async orderDetailFn() {
      const params = {
        mallOrderId: this.itemInfo.mallOrderId,
        orderNo: this.itemInfo.orderNo,
        // orId:this.itemInfo.orId,
        personId: this.itemInfo.personId,
      };
      const res = await orderDetail(params);
      if (res.code == 200) {
        this.bottomInfoList[1].value = res.data.orderDetail.payPhone;
        this.itemInfo.payTypeName = res.data.orderDetail.payTypeName;
      }
    },
    async updateConsultantNoticeStatusFn(id) {
      const params = {
        id: id,
        cnReadStatus: 1,
      };
      const res = await updateConsultantNoticeStatus(params);
    },
  },
  created() {
    // this.orderDetailFn();
    // this.bottomInfoList[0].value = this.itemInfo.productNum;
    this.bottomInfoList[0].value = this.itemInfo.personTelephone;
    // this.bottomInfoList[2].value = this.itemInfo.orderNo;
    this.bottomInfoList[1].value = this.itemInfo.cardTypeName;
    // this.bottomInfoList[4].value = this.itemInfo.payTime;
    if (this.isFinishEstimate) {
      this.height = 306;
    } else {
      if (this.consultantRateTime != "0") {
        this.height = 318;
      } else {
        this.height = 258;
      }
    }
    if (this.consultantRateTime != "0") {
      this.bottomInfoList.push({
        title: "完成服务时间",
        value: this.consultantRateTime,
      });
    }
  },
};
</script>

<style lang="scss" scoped>
.order-info {
  margin: 0 auto;
  width: 716rpx;
  //   height: 508rpx;
  background: #ffffff;
  border-radius: 16rpx;
  margin-bottom: 20rpx;
  .info-top {
    padding: 32rpx 32rpx 16rpx 32rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    .top-left {
      display: flex;
      flex-direction: row;
      align-items: center;
      image {
        width: 72rpx;
        height: 72rpx;
        border: 2rpx solid #ffffff;
        margin-right: 16rpx;
        border-radius: 50%;
      }
      .user-name {
        font-family: PingFang-SC, PingFang-SC;
        font-weight: bold;
        font-size: 32rpx;
        color: #333333;
      }
    }
    .top-right {
      display: flex;
      align-items: center;
      .new-order {
        width: 96rpx;
        height: 36rpx;
        background: #f75a3e;
        border-radius: 18rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24rpx;
        color: #ffffff;
        line-height: 24rpx;
        margin-right: 12rpx;
      }
      .arrow-right {
        width: 32rpx;
        height: 32rpx;
        color: #000000;
      }
    }
  }
  .info-middle {
    height: 72rpx;
    background: #f5f5f5;
    padding: 6rpx 32rpx;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    .middle-left {
      height: 46rpx;
      font-family: PingFang-SC, PingFang-SC;
      font-weight: bold;
      font-size: 36rpx;
      color: #333333;
      line-height: 46rpx;
    }
    .middle-right {
      display: flex;
      flex-direction: row;
      font-family: PingFang-SC, PingFang-SC;
      font-weight: 800;
      font-size: 24rpx;
      color: #ff711e;
      align-items: flex-end;
      .money {
      }
      .number {
        font-size: 36rpx;
        margin-bottom: -3rpx;
      }
    }
  }
  .info-bottom {
    padding: 32rpx;
    .bottom-item {
      margin-bottom: 16rpx;
      font-weight: 400;
      font-size: 28rpx;
      color: #666666;
    }
  }
  .info-bottom-finish-estimate {
    padding: 32rpx;
    .estimate {
      width: 100%;
      height: 92rpx;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 28rpx;
      line-height: 42rpx;
      color: #888888;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .date {
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 24rpx;
      color: #aaaaaa;
      margin-top: 18rpx;
    }
  }
}
</style>
